
<template>
  <div class="container pws-login">
    <!-- <div class="p-header">
      <div class="p-wrapper">
        <div class="title">
          <img src="../../../public/img/line-logo.png" alt="" />
        </div>
      </div>
    </div> -->
    <div class="p-center">
      <div class="p-wrapper">
        <div class="p-flex">
          <img src="../../../public/img/p-img.png" alt="" />
          <div class="login-card animated zoomInDown">
            <div class="login-title">
              <div class="login-tl">特作所物联管理平台</div>
            </div>
            <el-form :model="loginForm" :rules="loginRules" ref="loginForm" label-width="0" class="login_form" @submit.native.prevent>
                <el-form-item label="" label-width="0" prop="username">
                <el-input class="lang_input" placeholder="请输入您的用户名" prefix-icon="el-icon-user"  clearable v-model="loginForm.username"></el-input>
                </el-form-item>
                <el-form-item label="" label-width="0" prop="password">
                <el-input class="lang_input" :type="passwordType" placeholder="请输入您的密码" prefix-icon="el-icon-lock" show-password v-model="loginForm.password">
                    <i class="el-icon-view el-input__icon" slot="suffix" @click="showPassword"></i>
                </el-input>
                </el-form-item>
                <el-button type="primary" native-type="submit" @click="handleLogin('ruleForm')" class="lang_button" :loading="btnLoading">登 录</el-button>
            </el-form>
          </div>

        </div>
      </div>
    </div>
   <!-- <div class="p-footer">
      <div class="p-wrapper">
        <span>Copyright © 2021 重庆市坤演科技有限公司 版权所有</span>
      </div>
    </div> -->

  </div>
</template>

<script>
import { randomLenNum } from "@/util/util";
import { mapGetters } from "vuex";
export default {
  name: 'loginp',
  data () {
    return {
      loginForm: {
        username: "",
        password: "",
      },
      loginRules: {
        username: [
          { required: true, message: "请输入您的用户名", trigger: "blur" }
        ],
        password: [
          { required: true, message: "请输入密码", trigger: "blur" },
          { min: 6, message: "密码长度最少为6位", trigger: "blur" }
        ],
      },
      passwordType: "password",
      btnLoading: false,
    }
  },
  created() {

  },
  mounted() {

  },
  computed: {
    ...mapGetters(["tagWel"])
  },
  methods: {
    // 显示、隐藏 密码
    showPassword() {
      this.passwordType === "text"
        ? (this.passwordType = "password")
        : (this.passwordType = "text");
    },
    // 登录
    handleLogin() {
      this.$refs.loginForm.validate(valid => {
        if (valid) {
          this.btnLoading = true;
          this.$store.dispatch("LoginByUsername", this.loginForm).then((res) => {
            this.btnLoading = false;
            this.$router.push({ path: '/wel/index' });
          }).catch(() => {
            this.btnLoading = false;
          })
        }
      });
    }

  }
}
</script>
<style lang="scss">
html, body, #app {
  overflow: initial;
}
.pws-login {
  /**表单样式**/
  .login_form {
    margin-top: 40px;
    .el-form-item {
      margin-bottom: 30px;
      & + .el-form-item {
        margin-bottom: 20px;
      }
      .el-input__inner {
        height: 40px;
        line-height: 40px;
      }
      .el-input__icon {
        line-height: 40px;
        font-size: 18px;
      }
    }
  }
  .particles-js-canvas-el {
    position: absolute;
    z-index: 1;
    // pointer-events: none;
  }
}
</style>
<style lang="scss" scoped>
@media screen and (min-width:720px) and (max-width:1200px) {
    .pws-login {
      .p-flex {
        justify-content: center;
        img {
          display: none;
        }
      }
      .p-wrapper {
        width: 100%;
      }
      .p-header .title {
        justify-content: center;
      }

    }
}
@media screen and (max-width: 720px) {
  .pws-login {
    .p-flex {
        justify-content: center;
        img {
            display: none;
        }
    }
    .p-wrapper {
        width: 100%;
      }
    .p-header {
      display: none;
    }
    .p-footer {
      display: none;
    }
  }
}
.p-wrapper {
  width: 1200px;
  margin: 0 auto;
}
.container {
  height: 100%;
  display: flex;
  flex-direction: column;
  .p-header {
    height: 100px;
    line-height: 100px;
    position: relative;
    flex: none;
    .title {
      display: flex;
      align-items: center;
      img {
        height: 65px;
        margin-right: 20px;
        line-height: 110px;
        position: absolute;
        top: 50%;
        margin-top: -32.5px;
      }
      h1 {
        color: #00923F;
      }
    }
  }
  .p-center {
    flex: auto;
    background: url('../../../public/img/loginp.jpg') no-repeat;
    // background-size: cover;
	background-size:100% 100%;
	width: 100%;
	height: 100%;
    .p-wrapper {
      height: 100%;
    }
  }
  .p-footer {
    height: 70px;
    line-height: 70px;
    text-align: center;
    font-size: 14px;
    color: #646464;
    flex: none;
    span {
      display: inline-block;
      line-height: 16px;
    }
  }
}
.p-flex {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  img {
    width: auto;
    height: 0px;
    // height: 80%;
    // max-height: 400px;
  }
  .login-card {
    flex: none;
  }
}
.login-card {
  width: 400px;
  height: auto;
  background-color: #fff;
  border-radius: 10px;
  padding: 40px;
  box-sizing: border-box;
  position: relative;
  z-index: 2;
  margin-top:160px;
}
.login-title {
  display: flex;
  justify-content: center;
  align-items: center;
  color: #00923F;
  .login-tl {
    font-size: 22px;
  }
  .login-tr {
    height: 20px;
    line-height: 20px;
    cursor: pointer;
    img {
      width: 20px;
      height: 20px;
      vertical-align: top;
      margin-right: 5px;
    }
  }
}
.lang_button {
  background-color: #00923F;
  width: 100%;
  padding: 12px 20px;
  margin-top: 20px;
  font-size: 18px;
  border-color: #00923F;
}
.logo-header {
  display: flex;
  align-items: center;
  padding-bottom: 30px;
  margin-bottom: 30px;
  border-bottom: 1px solid #67c13a;
  img {
    width: 70px;
    height: 70px;
    margin-right: 20px;
  }
  h3 {
    color: #00923F;

  }
}
</style>

